package com.kvest.fragment_test.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.kvest.fragment_test.R;

/**
 * Created with IntelliJ IDEA.
 * User: r.belokon
 * Date: 07.03.13
 * Time: 18:10
 * To change this template use File | Settings | File Templates.
 */
public class FragmentOne extends BaseFragmen {
    private FragmentOneListener listener;

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try {
            listener = (FragmentOneListener)activity;
        } catch (ClassCastException cce) {
            Log.d("ERR", "activity must implements FragmentOneListener");
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Log.d(LOG_TAG, this.getClass().getName() + " onCreateView");

        View view = inflater.inflate(R.layout.ragment_one, null);

        view.findViewById(R.id.delete_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null) {
                    listener.onDeleteClick();
                }
            }
        });

        view.findViewById(R.id.replace_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null) {
                    listener.onReplaceClick();
                }
            }
        });

        return view;
    }

    public interface FragmentOneListener {
        public void onDeleteClick();
        public void onReplaceClick();
    }
}
